package cn.bugDance.domain.strategy.model.entity;

import cn.bugDance.types.common.Constants;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Arrays;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class StrategyEntity {

    private Long strategyId;

    /**
     * 策略级规则
     * 1. rule_blacklist 黑名单
     * 2. rule_weight 权重
     */
    private String ruleModels;

    /**
     * 判断策略是否存在该策略级规则
     * @param ruleModel
     * @return
     */
    public boolean isExistRuleModel(String ruleModel){
        if(null == ruleModels) return false;
        String[] ruleModelsArray = ruleModels.split(Constants.SPLIT);
        for(String ruleModelStr : ruleModelsArray){
            if(ruleModelStr.equals(ruleModel)) return true;
        }
        return false;
    }

}
